/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.coopeud.vista;

import edu.coopeud.vista.consultas.VentanaConsultas;
import edu.coopeud.vista.eventos.VentanaEventos;
import edu.coopeud.vista.registro.VentanaRegistro;

/**
 *
 * @author Alejo
 */
public class VentanaInicio extends javax.swing.JFrame {
    
    private VistaPrincipal principal;
    private VentanaConsultas consulta;
    private VentanaEventos evento;
    private VentanaRegistro registro;

    public VentanaInicio() {
        super("Vista de Inicio");
        initComponents();
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnCerrar = new javax.swing.JButton();
        btnRegistro = new javax.swing.JButton();
        btnEventos = new javax.swing.JButton();
        btnEstadisticas = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        btnCerrar.setText("Cerrar Sesión");
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });

        btnRegistro.setText("Registrar en un Evento");
        btnRegistro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistroActionPerformed(evt);
            }
        });

        btnEventos.setText("Gestionar Eventos");
        btnEventos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEventosActionPerformed(evt);
            }
        });

        btnEstadisticas.setText("Consultar Estadísticas");
        btnEstadisticas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEstadisticasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnEventos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnRegistro)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnEstadisticas)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnCerrar)
                .addGap(165, 165, 165))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnEventos)
                    .addComponent(btnRegistro)
                    .addComponent(btnEstadisticas))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnCerrar)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
       cerrar();
       getPrincipal().setVisible(true);
    }//GEN-LAST:event_btnCerrarActionPerformed

    private void btnRegistroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistroActionPerformed
        cerrar();
        getRegistro().setVisible(true);
    }//GEN-LAST:event_btnRegistroActionPerformed

    private void btnEventosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEventosActionPerformed
        cerrar();
        getEvento().setVisible(true);
    }//GEN-LAST:event_btnEventosActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        cerrar();
        getPrincipal().setVisible(true);
    }//GEN-LAST:event_formWindowClosing

    private void btnEstadisticasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEstadisticasActionPerformed
        cerrar();
        getConsulta().setVisible(true);
    }//GEN-LAST:event_btnEstadisticasActionPerformed

    public void cerrar(){
        dispose();
    }
    
    public VistaPrincipal getPrincipal (){
        if (principal==null){
            principal=new VistaPrincipal();
        }
        return principal;
    }
    
    public VentanaConsultas getConsulta (){
        if (consulta==null){
            consulta=new VentanaConsultas();
        }
        return consulta;
    }
    
    public VentanaEventos getEvento (){
        if (evento==null){
            evento=new VentanaEventos();
        }
        return evento;
    }
    
    public VentanaRegistro getRegistro (){
        if (registro==null){
            registro=new VentanaRegistro();
        }
        return registro;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCerrar;
    private javax.swing.JButton btnEstadisticas;
    private javax.swing.JButton btnEventos;
    private javax.swing.JButton btnRegistro;
    // End of variables declaration//GEN-END:variables
}
